home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 52
/
Amiga Format AFCD52 (Issue 136, May 2000).iso
/
-in_the_mag-
/
reader_requests
/
xgtool
/
xgtoolset
/
source
/
xgmain
/
xgmain.c
< prev
next >
Wrap
C/C++ Source or Header
|
2000-02-23
|
57KB
|
1,959 lines
/*
MNXG-Editor V1.6
A Bars and Pipes tool for editing the DB50-XG-board from YAMAHA. It's
also useable for other GM-equipment. But then don't touch the
Bank-slider.
Use it together with the other XG ... .ptool ' s -
© 1998 Alfred & Matthias Faust
The Tool-code based farly on the code for the "pc3.ptool" from Richard
Hagen. That's a very good tool, many thanks to him.
Richard has written his tool with DICE. We altered the code to compile
with the free GNU-C-compiler of the ADE. Especially the part was
transcripted, that place the imagedate in chip-RAM, because the
GNU-C-compiler hasn't as yet a keyword like DICE or other compiler for
this.
This code is released into the Public Domain, and may be freely
distributed in its original form.
It is supplied ``as is'', and comes with no warranty. This program code
was released because it might be useful as a starting point for other
programmers. However, if any damage arises from its use, the original
author and we will not be held liable.
You are free to use and modify this code to your heart's content,
provided you acknowledge me as the original author in any code that you
might distribute which is based largely on this code.
I acknowledge that the design of this tool is influenced strongly by
the example code supplied with the Rules for Tools package. However, I
have made substantial contributions of my own.
Matthias & Alfred Faust
j.k.dax@t-online.de
History:
1.0 (17.11.1998)
Initial Release.
Transcription from DB50XG.ptool
*/
#include "bars.h"
#include "myheader.h" // from R.Hagen
#include <libraries/dos.h>
#include <proto/exec.h>
#include <proto/intuition.h>
#include <proto/graphics.h>
#include <exec/memory.h>
#include <exec/execbase.h>
#include <exec/types.h>
#include <string.h>
#include <intuition/intuition.h>
#include "hexstrings.c" //translation hexbytes->hexstrings
#include "soundmatrix.c" //all the soundnames
char version[]="\0$VER:MNXG-Edit 1.0 (17.11.98) © Alfred & Matthias Faust";
#define MNXG_NAME "XG-Main-Edit"
#define MNXG_ID 0x344E5847
#define MNXG_TYPE (TOOL_NORMAL | TOOL_NOTPAD)
//Definitions of the controllers
#define CTR1 1 //Modulation
#define CTR7 7 //Main Volume
#define CTR10 10 //Panpot
#define CTR11 11 //Expression
#define CTR32 32 //Bank select in XG-Mode
#define CTR71 71 //Harmonic Content
#define CTR72 72 //Release Time
#define CTR73 73 //Attack Time
#define CTR74 74 //Brightness
#define CTR91 91 //Reverb Send Level
#define CTR93 93 //Chorus Send Level
#define CTR94 94 //Variation Send Level
// Hall-Effects 300 ->
#define hall1 0
#define hall2 1
#define room1 2
#define room2 3
#define room3 4
#define stage1 5
#define stage2 6
#define plate 7
#define whiteroom 8
#define tunnel 9
#define basement 10
/* the litte Icon in the pipeline */
UWORD *MNXG=NULL;
static UWORD MNXGdata[] =
{
/* Plane 0 */
0x7FFF, 0xFE00,
0x7FFF, 0xFE00,
0x6000, 0xF600,
0x6FEE, 0xE600,
0x6FDE, 0x0600,
0x6EF0, 0x0600,
0x6FDE, 0x0600,
0x6FBE, 0x0600,
0x6AB4, 0xE600,
0x6000, 0xF600,
0x7FFF, 0xFE00,
0x7FFF, 0xFE00,
/* Plane 1 */
0x0000, 0x0200,
0x0000, 0x0600,
0x0000, 0xF600,
0x0FFE, 0xEE00,
0x89FE, 0x1F00,
0x8EFE, 0x1F00,
0x89FE, 0x1F00,
0x8FBE, 0x1F00,
0x0AB6, 0xEE00,
0x0000, 0xF600,
0x1FFF, 0xFE00,
0x3FFF, 0xFE00,
/* Plane 2 */
0x0000, 0x0000,
0x0000, 0x0000,
0x0000, 0xF000,
0x0FFE, 0xE800,
0x0FFE, 0x1800,
0x0EF0, 0x7800,
0x0FDE, 0x7800,
0x0FFE, 0x1800,
0x0AF4, 0xE800,
0x0000, 0xF000,
0x0000, 0x0000,
0x0000, 0x0000
};
static struct Image MNXG_image = {
0, 0,
24 , 12 , 3 ,
NULL,
0x1f, 0x00,
NULL
};
//Definitions of the gadgets
#define VOLUME_GADGET 1
#define VOLUMEDOWN_GADGET 2
#define VOLUMEUP_GADGET 3
#define PANPOT_GADGET 4
#define PANPOTDOWN_GADGET 5
#define PANPOTUP_GADGET 6
#define REVERB_GADGET 7
#define REVERBDOWN_GADGET 8
#define REVERBUP_GADGET 9
#define CHORUS_GADGET 10
#define CHORUSDOWN_GADGET 11
#define CHORUSUP_GADGET 12
#define VARIATION_GADGET 13
#define VARIATIONDOWN_GADGET 14
#define VARIATIONUP_GADGET 15
#define HARMONIC_GADGET 16
#define HARMONICDOWN_GADGET 17
#define HARMONICUP_GADGET 18
#define BRIGHT_GADGET 19
#define BRIGHTDOWN_GADGET 20
#define BRIGHTUP_GADGET 21
#define VIBRATO_GADGET 22
#define VIBRATODOWN_GADGET 23
#define VIBRATOUP_GADGET 24
#define EXPRESSION_GADGET 25
#define EXPRESSIONDOWN_GADGET 26
#define EXPRESSIONUP_GADGET 27
#define ATTACK_GADGET 28
#define ATTACKDOWN_GADGET 29
#define ATTACKUP_GADGET 30
#define RELEASE_GADGET 31
#define RELEASEDOWN_GADGET 32
#define RELEASEUP_GADGET 33
#define BANK_GADGET 34
#define BANKDOWN_GADGET 35
#define BANKUP_GADGET 36
#define PC_GADGET 37
#define PCDOWN_GADGET 38
#define PCUP_GADGET 39
#define WRITE_GADGET 40
#define TEST_GADGET 41
#define P01_GADGET 42
#define DEFAULT_GADGET 43
#define INSY_GADGET 45
//all the gadgets
/* VOLUME gadget. */
struct PropInfo MNXGMNXGGadget1SInfo = {
AUTOKNOB|FREEHORIZ, -16384, -1, 16384, -1,
};
struct Image MNXGImage1 = {
0, 0, 102, 6, 0, NULL, 0x0000, 0x0000, NULL
};
struct IntuiText MNXGIText1 = {
2, 0, JAM1, -70, 1, NULL, " Volume", NULL
};
struct Gadget MNXGGadget1 = {
NULL, 89, 16, 200, 10, GFLG_GADGHBOX|GFLG_GADGHIMAGE, RELVERIFY|GADGIMMEDIATE, PROPGADGET,
(APTR)&MNXGImage1, NULL, &MNXGIText1, NULL, (APTR)&MNXGMNXGGadget1SInfo, VOLUME_GADGET, NULL
};
/* Panpot gadget. */
struct PropInfo MNXGMNXGGadget2SInfo = {
AUTOKNOB+FREEHORIZ, -16384, -1, 16384, -1,
};
struct Image MNXGImage2 = {
0, 0, 102, 6, 0, NULL, 0x0000, 0x0000, NULL
};
struct IntuiText MNXGIText2 = {
2, 0, JAM1, -70, 1, NULL, " Panpot", NULL
};
struct Gadget MNXGGadget2 = {
&MNXGGadget1, 89, 28, 200, 10, GFLG_GADGHBOX|GFLG_GADGHIMAGE, RELVERIFY|GADGIMMEDIATE, PROPGADGET,
(APTR)&MNXGImage2, NULL, &MNXGIText2, NULL, (APTR)&MNXGMNXGGadget2SInfo, PANPOT_GADGET, NULL
};
/* REVERB gadget. */
struct PropInfo MNXGMNXGGadget3SInfo = {
AUTOKNOB+FREEHORIZ, -16384, -1, 16384, -1,
};
struct Image MNXGImage3 = {
0, 0, 102, 6, 0, NULL, 0x0000, 0x0000, NULL
};
struct IntuiText MNXGIText3 = {
2, 0, JAM1, -70, 1, NULL, " Reverb", NULL
};
struct Gadget MNXGGadget3 = {
&MNXGGadget2, 89, 40, 200, 10, GFLG_GADGHBOX|GFLG_GADGHIMAGE, RELVERIFY|GADGIMMEDIATE, PROPGADGET,
(APTR)&MNXGImage3, NULL, &MNXGIText3, NULL, (APTR)&MNXGMNXGGadget3SInfo, REVERB_GADGET, NULL
};
/* Chorus gadget. */
struct PropInfo MNXGMNXGGadget4SInfo = {
AUTOKNOB+FREEHORIZ, -16384, -1, 16384, -1,
};
struct Image MNXGImage4 = {
0, 0, 102, 6, 0, NULL, 0x0000, 0x0000, NULL
};
struct IntuiText MNXGIText4 = {
2, 0, JAM1, -70, 1, NULL, " Chorus", NULL
};
struct Gadget MNXGGadget4 = {
&MNXGGadget3, 89, 52, 200, 10, GFLG_GADGHBOX|GFLG_GADGHIMAGE, RELVERIFY|GADGIMMEDIATE, PROPGADGET,
(APTR)&MNXGImage4, NULL, &MNXGIText4, NULL, (APTR)&MNXGMNXGGadget4SInfo, CHORUS_GADGET, NULL
};
// Variations gadget.
struct PropInfo MNXGMNXGGadget5SInfo = {
AUTOKNOB+FREEHORIZ, -16384, -1, 16384, -1,
};
struct Image MNXGImage5 = {
0, 0, 102, 6, 0, NULL, 0x0000, 0x0000, NULL
};
struct IntuiText MNXGIText5 = {
2, 0, JAM1, -70, 1, NULL, " Var-FX", NULL
};
struct Gadget MNXGGadget5 = {
&MNXGGadget4, 89, 64, 200, 10, GFLG_GADGHBOX|GFLG_GADGHIMAGE, RELVERIFY|GADGIMMEDIATE, PROPGADGET,
(APTR)&MNXGImage5, NULL, &MNXGIText5, NULL, (APTR)&MNXGMNXGGadget5SInfo, VARIATION_GADGET, NULL
};
/* HARMONIC gadget. */
struct PropInfo MNXGMNXGGadget6SInfo = {
AUTOKNOB+FREEHORIZ, -16384, -1, 16384, -1,
};
struct Image MNXGImage6 = {
0, 0, 102, 6, 0, NULL, 0x0000, 0x0000, NULL
};
struct IntuiText MNXGIText6 = {
2, 0, JAM1, -70, 1, NULL, "Harmonic", NULL
};
struct Gadget MNXGGadget6 = {
&MNXGGadget5, 89, 76, 200, 10, GFLG_GADGHBOX|GFLG_GADGHIMAGE, RELVERIFY|GADGIMMEDIATE, PROPGADGET,
(APTR)&MNXGImage6, NULL, &MNXGIText6, NULL, (APTR)&MNXGMNXGGadget6SInfo, HARMONIC_GADGET, NULL
};
/* BRIGHT */
struct PropInfo MNXGMNXGGadget7SInfo = {
AUTOKNOB+FREEHORIZ, -16384, -1, 16384, -1,
};
struct Image MNXGImage7 = {
0, 0, 102, 6, 0, NULL, 0x0000, 0x0000, NULL
};
struct IntuiText MNXGIText7 = {
2, 0, JAM1, -70, 1, NULL, " Bright", NULL
};
struct Gadget MNXGGadget7 = {
&MNXGGadget6, 89, 88, 200, 10, GFLG_GADGHBOX|GFLG_GADGHIMAGE, RELVERIFY|GADGIMMEDIATE, PROPGADGET,
(APTR)&MNXGImage7, NULL, &MNXGIText7, NULL, (APTR)&MNXGMNXGGadget7SInfo, BRIGHT_GADGET, NULL
};
/* Vibrato */
struct PropInfo MNXGMNXGGadget8SInfo = {
AUTOKNOB+FREEHORIZ, -16384, -1, 16384, -1,
};
struct Image MNXGImage8 = {
0, 0, 102, 6, 0, NULL, 0x0000, 0x0000, NULL
};
struct IntuiText MNXGIText8 = {
2, 0, JAM1, -70, 1, NULL, " Vibrato", NULL
};
struct Gadget MNXGGadget8 = {
&MNXGGadget7, 89, 100, 200, 10, GFLG_GADGHBOX|GFLG_GADGHIMAGE, RELVERIFY|GADGIMMEDIATE, PROPGADGET,
(APTR)&MNXGImage8, NULL, &MNXGIText8, NULL, (APTR)&MNXGMNXGGadget8SInfo, VIBRATO_GADGET, NULL
};
/* EXPRESSION */
struct PropInfo MNXGMNXGGadget9SInfo = {
AUTOKNOB|FREEHORIZ, -16384, -1, 16384, -1,
};
struct Image MNXGImage9 = {
00, 102, 6, 0, NULL, 0x0000, 0x0000, NULL
};
struct IntuiText MNXGIText9 = {
2, 0, JAM1, -70, 1, NULL, "Express.", NULL
};
struct Gadget MNXGGadget9 = {
&MNXGGadget8, 89, 112, 200, 10, GFLG_GADGHBOX|GFLG_GADGHIMAGE, RELVERIFY|GADGIMMEDIATE, PROPGADGET,
(APTR)&MNXGImage9, NULL, &MNXGIText9, NULL, (APTR)&MNXGMNXGGadget9SInfo, EXPRESSION_GADGET, NULL
};
/* ATTACK */
struct PropInfo MNXGMNXGGadget10SInfo = {
AUTOKNOB+FREEHORIZ, -16384, -1, 16384, -1,
};
struct Image MNXGImage10 = {
0, 0, 102, 6, 0, NULL, 0x0000, 0x0000, NULL
};
struct IntuiText MNXGIText10 = {
2, 0, JAM1, -70, 1, NULL, " Attack", NULL
};
struct Gadget MNXGGadget10 = {
&MNXGGadget9, 89, 124, 200, 10, GFLG_GADGHBOX|GFLG_GADGHIMAGE, RELVERIFY|GADGIMMEDIATE, PROPGADGET,
(APTR)&MNXGImage10, NULL, &MNXGIText10, NULL, (APTR)&MNXGMNXGGadget10SInfo, ATTACK_GADGET, NULL
};
/* RELEASE */
struct PropInfo MNXGMNXGGadget11SInfo = {
AUTOKNOB+FREEHORIZ, -16384, -1, 16384, -1,
};
struct Image MNXGImage11 = {
0, 0, 102, 6, 0, NULL, 0x0000, 0x0000, NULL
};
struct IntuiText MNXGIText11 = {
2, 0, JAM1, -70, 1, NULL, " Release", NULL
};
struct Gadget MNXGGadget11 = {
&MNXGGadget10, 89, 136, 200, 10, GFLG_GADGHBOX|GFLG_GADGHIMAGE, RELVERIFY|GADGIMMEDIATE, PROPGADGET,
(APTR)&MNXGImage11, NULL, &MNXGIText11, NULL, (APTR)&MNXGMNXGGadget11SInfo, RELEASE_GADGET, NULL
};
/* BANK gadget. */
struct PropInfo MNXGMNXGGadget12SInfo = {
AUTOKNOB+FREEHORIZ, -16384, -1, 16384, -1,
};
struct Image MNXGImage12 = {
0, 0, 102, 6, 0, NULL, 0x0000, 0x0000, NULL
};
struct IntuiText MNXGIText12 = {
2, 0, JAM1, -70, 1, NULL, " Bank", NULL
};
struct Gadget MNXGGadget12 = {
&MNXGGadget11, 89, 163, 200, 10, GFLG_GADGHBOX|GFLG_GADGHIMAGE, RELVERIFY|GADGIMMEDIATE, PROPGADGET,
(APTR)&MNXGImage12, NULL, &MNXGIText12, NULL, (APTR)&MNXGMNXGGadget12SInfo, BANK_GADGET, NULL
};
/* PC gadget. */
struct PropInfo MNXGMNXGGadget13SInfo = {
AUTOKNOB+FREEHORIZ, -16384, -1, 16384, -1,
};
struct Image MNXGImage13 = {
0, 0, 102, 6, 0, NULL, 0x0000, 0x0000, NULL
};
struct IntuiText MNXGIText13 = {
2, 0, JAM1, -70, 1, NULL, " Prgm#", NULL
};
struct Gadget MNXGGadget13 = {
&MNXGGadget12, 89, 175, 200, 10, GFLG_GADGHBOX|GFLG_GADGHIMAGE, RELVERIFY|GADGIMMEDIATE, PROPGADGET,
(APTR)&MNXGImage13, NULL, &MNXGIText13, NULL, (APTR)&MNXGMNXGGadget13SInfo, PC_GADGET, NULL
};
/* Write to track gadget. */
struct IntuiText MNXGIText14 = {
4, 0, JAM1, 4, 2, NULL, "Write to Track", NULL
};
struct Gadget MNXGGadget14 = {
&MNXGGadget13, 11, 195, 118, 11, GFLG_GADGHBOX|GFLG_GADGHIMAGE, RELVERIFY|GADGIMMEDIATE, BOOLGADGET,
NULL, NULL, &MNXGIText14, NULL, NULL, WRITE_GADGET, NULL
};
/* Test gadget. */
struct IntuiText MNXGIText15 = {
4, 0, JAM1, 4, 2, NULL, "Test", NULL
};
struct Gadget MNXGGadget15 = {
&MNXGGadget14, 279, 195, 40, 11, GFLG_GADGHBOX|GFLG_GADGHIMAGE, RELVERIFY|GADGIMMEDIATE, BOOLGADGET,
NULL, NULL, &MNXGIText15, NULL, NULL, TEST_GADGET, NULL
};
/* P01 gadget. */
struct IntuiText MNXGIText16 = {
4, 0, JAM1, 2, 2, NULL, "", NULL
};
struct Gadget MNXGGadget16 = {
&MNXGGadget15, 25, 175, 11, 11, GFLG_GADGHBOX|GFLG_GADGHIMAGE, RELVERIFY|GADGIMMEDIATE, BOOLGADGET,
NULL, NULL, &MNXGIText16, NULL, NULL, P01_GADGET, NULL
};
/* DEFAULT gadget. */
struct IntuiText MNXGIText17 = {
4, 0, JAM1, 4, 2, NULL, "Default", NULL
};
struct Gadget MNXGGadget17 = {
&MNXGGadget16, 173, 195, 65, 11, GFLG_GADGHBOX|GFLG_GADGHIMAGE, RELVERIFY|GADGIMMEDIATE, BOOLGADGET,
NULL, NULL, &MNXGIText17, NULL, NULL, DEFAULT_GADGET, NULL
};
UBYTE insy[] = {"I"};
/* VariationFX : Insertion<>System */
struct IntuiText MNXGIText18 = {
4, 0, JAM1, 1, 2, NULL, insy, NULL
};
struct Gadget MNXGGadget18 = {
&MNXGGadget17, 16, 63, 11, 11, GADGHBOX+GADGHIMAGE, GADGIMMEDIATE|TOGGLESELECT, BOOLGADGET,
NULL, NULL, &MNXGIText18, NULL, NULL, INSY_GADGET, NULL
};
//the mainwindowstructure
struct NewWindow MNXGNewWindowStructure1 = {
5, 15,
331, 215,
0, 6,
GADGETDOWN|GADGETUP|CLOSEWINDOW,
WINDOWDRAG|WINDOWDEPTH|WINDOWCLOSE|ACTIVATE|NOCAREREFRESH,
&MNXGGadget18,
NULL,
"XG Main Editor",
NULL,
NULL,
5, 5,
-1, -1,
CUSTOMSCREEN
};
extern struct ExecBase * SysBase;
UBYTE p, prgrm, banknr, ins=0;
struct MNXGTool {
struct Tool tool;
UBYTE volume;
UBYTE panpot;
UBYTE reverb;
UBYTE chorus;
UBYTE variation;
UBYTE harmonic;
UBYTE bright;
UBYTE vibrato;
UBYTE expression;
UBYTE attack;
UBYTE release;
UBYTE bank;
UBYTE pc;
char *insysysex;
char *resetsysex;
char *xgonsysex;
};
static struct ToolMaster master;
extern struct Functions *functions;
//initial values
static void MNXG_tool_init(struct MNXGTool *tool)
{
tool->tool.touched = TOUCH_INIT;
tool->volume = 100;
tool->panpot = 64;
tool->reverb = 40;
tool->chorus = 0;
tool->variation = 40;
tool->harmonic = 64;
tool->bright = 64;
tool->vibrato = 0;
tool->expression = 127;
tool->attack = 64;
tool->release = 64;
tool->bank = 0;
tool->pc = 0;
tool->insysysex = NULL;
tool->resetsysex = "F07E7F0901F7";
tool->xgonsysex = "F043104C00007E00F7";
}
static struct Event * __saveds processeventcode(struct Event *event)
{
event->tool = event->tool->next;
return(event);
}
static BOOL lock_clip(struct Clip *clip)
{
Forbid();
if (clip->locked == 0)
{
clip->locked = 1;
Permit();
return TRUE;
}
else
{
Permit();
return FALSE;
}
}
static void unlock_clip(struct Clip *clip)
{
clip->locked = 0;
}
static void send_pc(struct MNXGTool *tool, const long time)
{
struct Event *volume_event = (struct Event *)(*functions->allocevent)();
if (volume_event)
{
struct Event *panpot_event = (struct Event *)(*functions->allocevent)();
if (panpot_event)
{
struct Event *reverb_event = (struct Event *)(*functions->allocevent)();
if (reverb_event)
{
struct Event *chorus_event = (struct Event *)(*functions->allocevent)();
if (chorus_event)
{
struct Event *variation_event = (struct Event *)(*functions->allocevent)();
if (variation_event)
{
struct Event *harmonic_event = (struct Event *)(*functions->allocevent)();
if (harmonic_event)
{
struct Event *bright_event = (struct Event *)(*functions->allocevent)();
if (bright_event)
{
struct Event *vibrato_event = (struct Event *)(*functions->allocevent)();
if (vibrato_event)
{
struct Event *expression_event = (struct Event *)(*functions->allocevent)();
if (expression_event)
{
struct Event *attack_event = (struct Event *)(*functions->allocevent)();
if (attack_event)
{
struct Event *release_event = (struct Event *)(*functions->allocevent)();
if (release_event)
{
struct Event *bank_event = (struct Event *)(*functions->allocevent)();
if (bank_event)
{
struct Event *pc_event = (struct Event *)(*functions->allocevent)();
if (pc_event)
{
volume_event->type =
panpot_event->type =
reverb_event->type =
chorus_event->type =
variation_event->type =
harmonic_event->type =
bright_event->type =
vibrato_event->type =
expression_event->type =
attack_event->type =
release_event->type =
bank_event->type =
pc_event->type = EVENT_VOICE;
volume_event->status = MIDI_CCHANGE;
volume_event->byte1 = CTR7;
volume_event->byte2 = tool->volume;
panpot_event->status = MIDI_CCHANGE;
panpot_event->byte1 = CTR10;
panpot_event->byte2 = tool->panpot;
reverb_event->status = MIDI_CCHANGE;
reverb_event->byte1 = CTR91;
reverb_event->byte2 = tool->reverb;
chorus_event->status = MIDI_CCHANGE;
chorus_event->byte1 = CTR93;
chorus_event->byte2 = tool->chorus;
variation_event->status = MIDI_CCHANGE;
variation_event->byte1 = CTR94;
variation_event->byte2 = tool->variation;
harmonic_event->status = MIDI_CCHANGE;
harmonic_event->byte1 = CTR71;
harmonic_event->byte2 = tool->harmonic;
bright_event->status = MIDI_CCHANGE;
bright_event->byte1 = CTR74;
bright_event->byte2 = tool->bright;
vibrato_event->status = MIDI_CCHANGE;
vibrato_event->byte1 = CTR1;
vibrato_event->byte2 = tool->vibrato;
expression_event->status = MIDI_CCHANGE;
expression_event->byte1 = CTR11;
expression_event->byte2 = tool->expression;
attack_event->status = MIDI_CCHANGE;
attack_event->byte1 = CTR73;
attack_event->byte2 = tool->attack;
release_event->status = MIDI_CCHANGE;
release_event->byte1 = CTR72;
release_event->byte2 = tool->release;
bank_event->status = MIDI_CCHANGE;
bank_event->byte1 = CTR32;
bank_event->byte2 = banknr;
pc_event->status = MIDI_PCHANGE;
pc_event->byte1 = tool->pc;
volume_event->time = time;
panpot_event->time = time;
reverb_event->time = time;
chorus_event->time = time;
variation_event->time = time;
harmonic_event->time = time;
bright_event->time = time;
vibrato_event->time = time;
expression_event->time = time;
attack_event->time = time;
release_event->time = time;
bank_event->time = time;
pc_event->time = time+1;
volume_event->tool =
panpot_event->tool =
reverb_event->tool =
chorus_event->tool =
variation_event->tool =
harmonic_event->tool =
bright_event->tool =
vibrato_event->tool =
expression_event->tool =
attack_event->tool =
release_event->tool =
bank_event->tool =
pc_event->tool = tool->tool.next;
volume_event->next =
panpot_event->next =
reverb_event->next =
chorus_event->next =
variation_event->next =
harmonic_event->next =
bright_event->next =
vibrato_event->next =
expression_event->next =
attack_event->next =
release_event->next =
bank_event->next =
pc_event->next = NULL;
(*functions->qevent)(volume_event);
(*functions->qevent)(panpot_event);
(*functions->qevent)(reverb_event);
(*functions->qevent)(chorus_event);
(*functions->qevent)(variation_event);
(*functions->qevent)(harmonic_event);
(*functions->qevent)(bright_event);
(*functions->qevent)(vibrato_event);
(*functions->qevent)(expression_event);
(*functions->qevent)(attack_event);
(*functions->qevent)(release_event);
(*functions->qevent)(bank_event);
(*functions->qevent)(pc_event);
}
else
{
(*functions->freeevent)(volume_event);
(*functions->freeevent)(panpot_event);
(*functions->freeevent)(reverb_event);
(*functions->freeevent)(chorus_event);
(*functions->freeevent)(variation_event);
(*functions->freeevent)(harmonic_event);
(*functions->freeevent)(bright_event);
(*functions->freeevent)(vibrato_event);
(*functions->freeevent)(expression_event);
(*functions->freeevent)(attack_event);
(*functions->freeevent)(release_event);
(*functions->freeevent)(bank_event);
}
}
else
{
(*functions->freeevent)(volume_event);
(*functions->freeevent)(panpot_event);
(*functions->freeevent)(reverb_event);
(*functions->freeevent)(chorus_event);
(*functions->freeevent)(variation_event);
(*functions->freeevent)(harmonic_event);
(*functions->freeevent)(bright_event);
(*functions->freeevent)(vibrato_event);
(*functions->freeevent)(expression_event);
(*functions->freeevent)(attack_event);
(*functions->freeevent)(release_event);
}
}
else
{
(*functions->freeevent)(volume_event);
(*functions->freeevent)(panpot_event);
(*functions->freeevent)(reverb_event);
(*functions->freeevent)(chorus_event);
(*functions->freeevent)(variation_event);
(*functions->freeevent)(harmonic_event);
(*functions->freeevent)(bright_event);
(*functions->freeevent)(vibrato_event);
(*functions->freeevent)(expression_event);
(*functions->freeevent)(attack_event);
}
}
else
{
(*functions->freeevent)(volume_event);
(*functions->freeevent)(panpot_event);
(*functions->freeevent)(reverb_event);
(*functions->freeevent)(chorus_event);
(*functions->freeevent)(variation_event);
(*functions->freeevent)(harmonic_event);
(*functions->freeevent)(bright_event);
(*functions->freeevent)(vibrato_event);
(*functions->freeevent)(expression_event);
}
}
else
{
(*functions->freeevent)(volume_event);
(*functions->freeevent)(panpot_event);
(*functions->freeevent)(reverb_event);
(*functions->freeevent)(chorus_event);
(*functions->freeevent)(variation_event);
(*functions->freeevent)(harmonic_event);
(*functions->freeevent)(bright_event);
(*functions->freeevent)(vibrato_event);
}
}
else
{
(*functions->freeevent)(volume_event);
(*functions->freeevent)(panpot_event);
(*functions->freeevent)(reverb_event);
(*functions->freeevent)(chorus_event);
(*functions->freeevent)(variation_event);
(*functions->freeevent)(harmonic_event);
(*functions->freeevent)(bright_event);
}
}
else
{
(*functions->freeevent)(volume_event);
(*functions->freeevent)(panpot_event);
(*functions->freeevent)(reverb_event);
(*functions->freeevent)(chorus_event);
(*functions->freeevent)(variation_event);
(*functions->freeevent)(harmonic_event);
}
}
else
{
(*functions->freeevent)(volume_event);
(*functions->freeevent)(panpot_event);
(*functions->freeevent)(reverb_event);
(*functions->freeevent)(chorus_event);
(*functions->freeevent)(variation_event);
}
}
else
{
(*functions->freeevent)(volume_event);
(*functions->freeevent)(panpot_event);
(*functions->freeevent)(reverb_event);
(*functions->freeevent)(chorus_event);
}
}
else
{
(*functions->freeevent)(volume_event);
(*functions->freeevent)(panpot_event);
(*functions->freeevent)(reverb_event);
}
}
else
{
(*functions->freeevent)(volume_event);
(*functions->freeevent)(panpot_event);
}
}
else
{
(*functions->freeevent)(volume_event);
}
}
}
//writes sysex into track
static void __saveds insertsysex(char *buff, short size, struct MNXGTool *tool, const LONG time)
{
struct StringEvent *event;
struct String *string;
event = (struct StringEvent *) (*functions->allocevent)();
if (event)
{
string = (struct String *) (*functions->myalloc)(size + 3, MEMF_CLEAR);
if (string)
{
event->next = NULL;
event->string = string;
memcpy(string->string, buff, size);
string->length = size + 2;
event->type = EVENT_SYSX;
event->status = MIDI_SYSX;
event->time = time;
event->tool = tool->tool.next;
if (lock_clip(&(tool->tool.track->clip)))
{
event->next = (struct StringEvent *)tool->tool.track->clip.events.first;
tool->tool.track->clip.events.first = (struct Event *)(*functions->sorteventlist)(event);
unlock_clip(&(tool->tool.track->clip));
}
else
{
(*functions->freelist)(event);
}
}
}
}
// the routine for sending SysEx-data thru the pipeline
static void __saveds sendsysex(char *buff, short size, struct MNXGTool *tool, const LONG time)
{
struct StringEvent *event;
struct String *string;
event = (struct StringEvent *) (*functions->allocevent)();
if (event)
{
string = (struct String *) (*functions->myalloc)(size + 3, MEMF_CLEAR);
if (string)
{
event->string = string;
memcpy(string->string, buff, size);
string->length = size + 2;
event->type = EVENT_SYSX;
event->status = MIDI_SYSX;
event->time = time;
event->tool = tool->tool.next;
WaitTOF();
(*functions->qevent)(event);
(*functions->myfree)(string);
}
}
}
static void __saveds trans_hx(struct MNXGTool *tool, const LONG time, char *sysx, int sw)
{
LONG size;
int a, b, x, y ;
UBYTE abuf[32];
char chr[4];
char *zbuf = NULL;
struct Event *sysx_event;
//translate sysexbuffer into hex
size = strlen(sysx);
zbuf = (char *)AllocVec(size+2, MEMF_ANY|MEMF_CLEAR);
if(zbuf)
{
CopyMem(sysx, zbuf, size);
b=0;
for(a=0;a < size;a=a+2)
{
chr[0] = zbuf[a];
chr[1] = zbuf[a+1];
x=(isdigit((int)chr[0]))? (chr[0]&0xF) : ((chr[0]&0xDF)-55); //this is the
y=(isdigit((int)chr[1]))? (chr[1]&0xF) : ((chr[1]&0xDF)-55); //the translate-core
abuf[b++] = ((x<<4)|y); //writing with bitmanipulation
}
//send hexdata
FreeVec(zbuf);
if (sw == 0) sendsysex(abuf, b, tool, time);
if (sw == 1) insertsysex(abuf, b, tool, time);
}
}
// Writes all values of the sliders and more in the main window
long __saveds display_routine(struct Window *window, /* Window where the gadget lives. */
struct Gadget *gadget, /* The gadget itself. */
unsigned long value) /* The value to display. */
{
char text[10];
char tname[32];
char P01text[4];
char varfx01text[4];
const short id = gadget->GadgetID;
struct RastPort *rp = window->RPort;
char name[15];
int i=0;
UBYTE bnk[]=
{0, 1, 3, 6, 8, 12, 14, 16, 17, 18, 19, 20, 24, 25, 27, 28, 32, 33, 34, 35, 36, 37, 38, 40,
41, 42, 43, 45, 64, 65, 66, 67, 68, 69, 70, 71, 72, 96, 97, 98, 99, 100, 101};
UBYTE bnkval[]=
{0, 1, 3, 6, 8, 12, 14, 16, 17, 18, 19, 20, 24, 25, 27, 28, 32, 33, 34, 35, 36, 37, 38, 40,
41, 42, 43, 45, 64, 65, 66, 67, 68, 69, 70, 71, 72, 96, 97, 98, 99, 100, 101};
SetAPen(rp, 1);
SetBPen(rp, 0);
SetDrMd(rp, JAM2);
switch (id)
{
case VOLUME_GADGET:
Move(rp, 297, 23);
sprintf(text, "%3ld", value);
Text(rp, text, 3);
break;
case PANPOT_GADGET:
Move(rp, 297, 35);
sprintf(text, "%3ld", value);
Text(rp, text, 3);
break;
case REVERB_GADGET:
Move(rp, 297, 47);
sprintf(text, "%3ld", value);
Text(rp, text, 3);
break;
case CHORUS_GADGET:
Move(rp, 297, 59);
sprintf(text, "%3ld", value);
Text(rp, text, 3);
break;
case VARIATION_GADGET:
Move(rp, 297, 71);
sprintf(text, "%3ld", value);
Text(rp, text, 3);
break;
case HARMONIC_GADGET:
Move(rp, 297, 83);
sprintf(text, "%3ld", value);
Text(rp, text, 3);
break;
case BRIGHT_GADGET:
Move(rp, 297, 95);
sprintf(text, "%3ld", value);
Text(rp, text, 3);
break;
case VIBRATO_GADGET:
Move(rp, 297, 107);
sprintf(text, "%3ld", value);
Text(rp, text, 3);
break;
case EXPRESSION_GADGET:
Move(rp, 297, 119);
sprintf(text, "%3ld", value);
Text(rp, text, 3);
break;
case ATTACK_GADGET:
Move(rp, 297, 131);
sprintf(text, "%3ld", value);
Text(rp, text, 3);
break;
case RELEASE_GADGET:
Move(rp, 297, 143);
sprintf(text, "%3ld", value);
Text(rp, text, 3);
break;
case BANK_GADGET:
banknr = bnk[value];
sprintf(text, "%3ld", banknr);
Move(rp, 297, 170);
Text(rp, text, 3);
break;
case PC_GADGET:
prgrm = value;
Move(rp, 297, 182);
if (p == 0) sprintf(text, "%3ld", prgrm);
else if (p ==1) sprintf(text, "%3ld", prgrm+1);
Text(rp, text, 3);
break;
default:
break;
}
sprintf(P01text, "%1ld", p);
Move(rp, 9, 182);
Text(rp, P01text, 1);
sprintf(tname, "Name:%15.15s", (matrix[banknr * MAX_PROGRAMS+prgrm])?(char *)matrix[banknr * MAX_PROGRAMS+prgrm]:(char *)EMPTY);
SetAPen(rp, 4);
SetBPen(rp, 7);
SetDrMd(rp, INVERSVID|JAM2);
Move(rp, 88, 157);
Text(rp, tname, strlen(tname));
return (value);
}
//Drag & draw functions for the gadgets
static long drag_embossed_prop(struct Window *window, short id, UBYTE min)
{
long value = (*functions->DragEmbossedProp)(window, id);
if (value < min)
{
value = min;
(*functions->ModifyEmbossedProp)(window, id, value, 0, 0, 0, 0, 0);
}
(*functions->DrawEmbossedProp)(window, id);
return value;
}
static long shift_embossed_prop(struct Window *window, short id, short shift, UBYTE min)
{
long value = (*functions->ShiftEmbossedProp)(window, id, shift, 0);
if (value < min)
{
value = min;
(*functions->ModifyEmbossedProp)(window, id, value, 0, 0, 0, 0, 0);
}
(*functions->DrawEmbossedProp)(window, id);
return value;
}
//handels writing the values to track
static void insert_pc(struct MNXGTool *tool)
{
if (!functions->running)
{
const long time = functions->starttime;
struct Event *volume_event = (struct Event *)(*functions->allocevent)();
if (volume_event)
{
struct Event *panpot_event = (struct Event *)(*functions->allocevent)();
if (panpot_event)
{
struct Event *reverb_event = (struct Event *)(*functions->allocevent)();
if (reverb_event)
{
struct Event *chorus_event = (struct Event *)(*functions->allocevent)();
if (chorus_event)
{
struct Event *variation_event = (struct Event *)(*functions->allocevent)();
if (variation_event)
{
struct Event *harmonic_event = (struct Event *)(*functions->allocevent)();
if (harmonic_event)
{
struct Event *bright_event = (struct Event *)(*functions->allocevent)();
if (bright_event)
{
struct Event *vibrato_event = (struct Event *)(*functions->allocevent)();
if (vibrato_event)
{
struct Event *expression_event = (struct Event *)(*functions->allocevent)();
if (expression_event)
{
struct Event *attack_event = (struct Event *)(*functions->allocevent)();
if (attack_event)
{
struct Event *release_event = (struct Event *)(*functions->allocevent)();
if (release_event)
{
struct Event *bank_event = (struct Event *)(*functions->allocevent)();
if (bank_event)
{
struct Event *pc_event = (struct Event *)(*functions->allocevent)();
if (pc_event)
{
volume_event->type =
panpot_event->type =
reverb_event->type =
chorus_event->type =
variation_event->type =
harmonic_event->type =
bright_event->type =
vibrato_event->type =
expression_event->type =
attack_event->type =
release_event->type =
bank_event->type =
pc_event->type = EVENT_VOICE;
volume_event->status =
panpot_event->status =
reverb_event->status =
chorus_event->status =
variation_event->status =
harmonic_event->status =
bright_event->status =
vibrato_event->status =
expression_event->status =
attack_event->status =
release_event->status =
bank_event->status = MIDI_CCHANGE;
volume_event->byte1 = CTR7;
volume_event->byte2 = tool->volume;
panpot_event->byte1 = CTR10;
panpot_event->byte2 = tool->panpot;
reverb_event->byte1 = CTR91;
reverb_event->byte2 = tool->reverb;
chorus_event->byte1 = CTR93;
chorus_event->byte2 = tool->chorus;
variation_event->byte1 = CTR94;
variation_event->byte2 = tool->variation;
harmonic_event->byte1 = CTR71;
harmonic_event->byte2 = tool->harmonic;
bright_event->byte1 = CTR74;
bright_event->byte2 = tool->bright;
vibrato_event->byte1 = CTR1;
vibrato_event->byte2 = tool->vibrato;
expression_event->byte1 = CTR11;
expression_event->byte2 = tool->expression;
attack_event->byte1 = CTR73;
attack_event->byte2 = tool->attack;
release_event->byte1 = CTR72;
release_event->byte2 = tool->release;
bank_event->byte1 = CTR32;
bank_event->byte2 = banknr;
pc_event->status = MIDI_PCHANGE;
pc_event->byte1 = tool->pc;
volume_event->time = time;
panpot_event->time = time;
reverb_event->time = time;
chorus_event->time = time;
variation_event->time = time;
harmonic_event->time = time;
bright_event->time = time;
vibrato_event->time = time;
expression_event->time = time;
attack_event->time = time;
release_event->time = time;
bank_event->time = time;
pc_event->time = time + 1;
volume_event->tool =
panpot_event->tool =
reverb_event->tool =
chorus_event->tool =
variation_event->tool =
harmonic_event->tool =
bright_event->tool =
vibrato_event->tool =
expression_event->tool =
attack_event->tool =
release_event->tool =
bank_event->tool =
pc_event->tool = tool->tool.next;
volume_event->next = panpot_event;
panpot_event->next = reverb_event;
reverb_event->next = chorus_event;
chorus_event->next = variation_event;
variation_event->next = harmonic_event;
harmonic_event->next = bright_event;
bright_event->next = vibrato_event;
vibrato_event->next = expression_event;
expression_event->next = attack_event;
attack_event->next = release_event;
release_event->next = bank_event;
bank_event->next = pc_event;
pc_event->next = NULL;
if (lock_clip(&(tool->tool.track->clip)))
{
pc_event->next = tool->tool.track->clip.events.first;
tool->tool.track->clip.events.first =
(struct Event *)(*functions->sorteventlist)(volume_event);
unlock_clip(&(tool->tool.track->clip));
}
else
{
(*functions->freelist)(volume_event);
}
}
else
{
(*functions->freeevent)(volume_event);
(*functions->freeevent)(panpot_event);
(*functions->freeevent)(reverb_event);
(*functions->freeevent)(chorus_event);
(*functions->freeevent)(harmonic_event);
(*functions->freeevent)(variation_event);
(*functions->freeevent)(bright_event);
(*functions->freeevent)(vibrato_event);
(*functions->freeevent)(expression_event);
(*functions->freeevent)(attack_event);
(*functions->freeevent)(release_event);
(*functions->freeevent)(bank_event);
}
}
else
{
(*functions->freeevent)(volume_event);
(*functions->freeevent)(panpot_event);
(*functions->freeevent)(reverb_event);
(*functions->freeevent)(chorus_event);
(*functions->freeevent)(variation_event);
(*functions->freeevent)(harmonic_event);
(*functions->freeevent)(bright_event);
(*functions->freeevent)(vibrato_event);
(*functions->freeevent)(expression_event);
(*functions->freeevent)(attack_event);
(*functions->freeevent)(release_event);
}
}
else
{
(*functions->freeevent)(volume_event);
(*functions->freeevent)(panpot_event);
(*functions->freeevent)(reverb_event);
(*functions->freeevent)(chorus_event);
(*functions->freeevent)(variation_event);
(*functions->freeevent)(harmonic_event);
(*functions->freeevent)(bright_event);
(*functions->freeevent)(vibrato_event);
(*functions->freeevent)(expression_event);
(*functions->freeevent)(attack_event);
}
}
else
{
(*functions->freeevent)(volume_event);
(*functions->freeevent)(panpot_event);
(*functions->freeevent)(reverb_event);
(*functions->freeevent)(chorus_event);
(*functions->freeevent)(variation_event);
(*functions->freeevent)(harmonic_event);
(*functions->freeevent)(bright_event);
(*functions->freeevent)(vibrato_event);
(*functions->freeevent)(expression_event);
}
}
else
{
(*functions->freeevent)(volume_event);
(*functions->freeevent)(panpot_event);
(*functions->freeevent)(reverb_event);
(*functions->freeevent)(chorus_event);
(*functions->freeevent)(variation_event);
(*functions->freeevent)(harmonic_event);
(*functions->freeevent)(bright_event);
(*functions->freeevent)(vibrato_event);
}
}
else
{
(*functions->freeevent)(volume_event);
(*functions->freeevent)(panpot_event);
(*functions->freeevent)(reverb_event);
(*functions->freeevent)(chorus_event);
(*functions->freeevent)(variation_event);
(*functions->freeevent)(harmonic_event);
(*functions->freeevent)(bright_event);
}
}
else
{
(*functions->freeevent)(volume_event);
(*functions->freeevent)(panpot_event);
(*functions->freeevent)(reverb_event);
(*functions->freeevent)(chorus_event);
(*functions->freeevent)(variation_event);
(*functions->freeevent)(harmonic_event);
}
}
else
{
(*functions->freeevent)(volume_event);
(*functions->freeevent)(panpot_event);
(*functions->freeevent)(reverb_event);
(*functions->freeevent)(chorus_event);
(*functions->freeevent)(variation_event);
}
}
else
{
(*functions->freeevent)(volume_event);
(*functions->freeevent)(panpot_event);
(*functions->freeevent)(reverb_event);
(*functions->freeevent)(chorus_event);
}
}
else
{
(*functions->freeevent)(volume_event);
(*functions->freeevent)(panpot_event);
(*functions->freeevent)(reverb_event);
}
}
else
{
(*functions->freeevent)(volume_event);
(*functions->freeevent)(panpot_event);
}
}
else
{
(*functions->freeevent)(volume_event);
}
}
}
}
//to hear the changes
static void send_note(struct MNXGTool *tool, const long time, const UBYTE note)
{
struct NoteEvent *on_event = (struct NoteEvent *)(*functions->allocevent)();
if (on_event)
{
struct NoteEvent *off_event = (struct NoteEvent *)(*functions->allocevent)();
if (off_event)
{
on_event->next =
off_event->next = NULL;
on_event->type =
off_event->type = EVENT_VOICE;
on_event->status = MIDI_NOTEON;
off_event->status = MIDI_NOTEOFF;
on_event->value =
off_event->value = note;
on_event->velocity = 80;
on_event->time = time;
off_event->time = time + 96;
on_event->tool =
off_event->tool = tool->tool.next;
(*functions->qevent)(on_event);
(*functions->qevent)(off_event);
}
else
{
(*functions->freeevent)(on_event);
}
}
}
static void send_pc_and_note(struct MNXGTool *tool, const long time, const UBYTE note)
{
send_pc(tool, time);
send_note(tool, time + 3, note);
}
//the center off all
static void __saveds edittoolcode(struct MNXGTool *tool)
{
struct IntuiMessage *message;
struct Window *window;
LONG class, code, time;
struct Gadget *gadget;
struct NewWindow *newwindow;
int i, revres=0;
UBYTE bankval;
char *revtypebt, *storagebt;
char revtypebyte[11][4] ={
"0100", "0101", "0202", "0201", "0202", "0300", "0301", "0400", "1000", "1100", "1300"};
MNXGNewWindowStructure1.Screen = functions->screen;
if (tool->tool.touched & TOUCH_EDIT)
{
MNXGNewWindowStructure1.LeftEdge = tool->tool.left;
MNXGNewWindowStructure1.TopEdge = tool->tool.top;
MNXGNewWindowStructure1.Width = tool->tool.width;
MNXGNewWindowStructure1.Height = tool->tool.height;
}
if (!tool->tool.touched)
{
MNXG_tool_init(tool);
}
newwindow = (struct NewWindow *) (*functions->DupeNewWindow)(&MNXGNewWindowStructure1);
if (!newwindow)
{
return;
}
newwindow->Title = 0;
newwindow->Flags |= BORDERLESS;
newwindow->Flags &= ~0xF;
newwindow->BlockPen = 0;
newwindow->DetailPen = 0;
window = (struct Window *) (*functions->FlashyOpenWindow)(newwindow);
if (!window)
{
return;
}
tool->tool.window = window;
(*functions->EmbossWindowOn)(window, WINDOWCLOSE|WINDOWDEPTH|WINDOWDRAG, MNXG_NAME, (short)-1, (short)-1, 0, 0);
// because these sliders are identical we can use a loop
for (i = VOLUME_GADGET;
i <= PC_GADGET;
i += 3)
{
if (!(i == BANK_GADGET))
{
(*functions->FatEmbossedPropOn)(window,i, i + 1, i + 2,
(void *)display_routine,
128, 1);
}
else
{
(*functions->FatEmbossedPropOn)(window,
BANK_GADGET,
BANKDOWN_GADGET,
BANKUP_GADGET,
(void *)display_routine,
43, 1);
}
}
(*functions->EmbossOn)(window, WRITE_GADGET, 1);
(*functions->EmbossOn)(window, TEST_GADGET, 1);
(*functions->EmbossOn)(window, P01_GADGET, 1);
(*functions->EmbossOn)(window, DEFAULT_GADGET, 1);
(*functions->EmbossOn)(window, INSY_GADGET, 1);
(*functions->ModifyEmbossedProp)(window, VOLUME_GADGET, tool->volume, 0, 0, 0, 0, 0);
(*functions->ModifyEmbossedProp)(window, PANPOT_GADGET, tool->panpot, 0, 0, 0, 0, 0);
(*functions->ModifyEmbossedProp)(window, REVERB_GADGET, tool->reverb, 0, 0, 0, 0, 0);
(*functions->ModifyEmbossedProp)(window, CHORUS_GADGET, tool->chorus, 0, 0, 0, 0, 0);
(*functions->ModifyEmbossedProp)(window, VARIATION_GADGET, tool->variation, 0, 0, 0, 0, 0);
(*functions->ModifyEmbossedProp)(window, HARMONIC_GADGET, tool->harmonic, 0, 0, 0, 0, 0);
(*functions->ModifyEmbossedProp)(window, BRIGHT_GADGET, tool->bright, 0, 0, 0, 0, 0);
(*functions->ModifyEmbossedProp)(window, VIBRATO_GADGET, tool->vibrato, 0, 0, 0, 0, 0);
(*functions->ModifyEmbossedProp)(window, EXPRESSION_GADGET, tool->expression, 0, 0, 0, 0, 0);
(*functions->ModifyEmbossedProp)(window, ATTACK_GADGET, tool->attack, 0, 0, 0, 0, 0);
(*functions->ModifyEmbossedProp)(window, RELEASE_GADGET, tool->release, 0, 0, 0, 0, 0);
(*functions->ModifyEmbossedProp)(window, BANK_GADGET, tool->bank, 0, 0, 0, 0, 0);
(*functions->ModifyEmbossedProp)(window, PC_GADGET, tool->pc, 0, 0, 0, 0, 0);
for (i = VOLUME_GADGET;
i <= PC_GADGET;
i += 3)
{
(*functions->DrawEmbossedProp)(window, i);
}
send_pc_and_note(tool, functions->timenow, 60);
for (;;)
{
(*functions->SelectEmbossed)(window, INSY_GADGET, ins);
message = (struct IntuiMessage *) (*functions->GetIntuiMessage)(window);
class = message->Class;
code = message->Code;
gadget = (struct Gadget *) message->IAddress;
class = (*functions->SystemGadgets)(window, class, gadget, code);
ReplyMsg((struct Message *)message);
if (class == CLOSEWINDOW)
{
break;
}
else if (class == GADGETDOWN)
{
const short id = gadget->GadgetID;
switch (id)
{
case VOLUME_GADGET:
tool->volume = (UBYTE) drag_embossed_prop(window, VOLUME_GADGET, 0);
send_pc_and_note(tool, functions->timenow, 60);
break;
case VOLUMEDOWN_GADGET:
tool->volume = (UBYTE) shift_embossed_prop(window, VOLUME_GADGET, -1, 0);
send_pc_and_note(tool, functions->timenow, 60);
break;
case VOLUMEUP_GADGET:
tool->volume = (UBYTE) shift_embossed_prop(window, VOLUME_GADGET, 1, 0);
send_pc_and_note(tool, functions->timenow, 60);
break;
case PANPOT_GADGET:
tool->panpot = (UBYTE) drag_embossed_prop(window, PANPOT_GADGET, 0);
send_pc_and_note(tool, functions->timenow, 60);
break;
case PANPOTDOWN_GADGET:
tool->panpot = (UBYTE)shift_embossed_prop(window, PANPOT_GADGET, -1, 0);
send_pc_and_note(tool, functions->timenow, 60);
break;
case PANPOTUP_GADGET:
tool->panpot = (UBYTE) shift_embossed_prop(window, PANPOT_GADGET, 1, 0);
send_pc_and_note(tool, functions->timenow, 60);
break;
case REVERB_GADGET:
tool->reverb = (UBYTE) drag_embossed_prop(window, REVERB_GADGET, 0);
send_pc_and_note(tool, functions->timenow, 60);
break;
case REVERBDOWN_GADGET:
tool->reverb = (UBYTE) shift_embossed_prop(window, REVERB_GADGET, -1, 0);
send_pc_and_note(tool, functions->timenow, 60);
break;
case REVERBUP_GADGET:
tool->reverb = (UBYTE) shift_embossed_prop(window, REVERB_GADGET, 1, 0);
send_pc_and_note(tool, functions->timenow, 60);
break;
case CHORUS_GADGET:
tool->chorus = (UBYTE) drag_embossed_prop(window, CHORUS_GADGET, 0);
send_pc_and_note(tool, functions->timenow, 60);
break;
case CHORUSDOWN_GADGET:
tool->chorus = (UBYTE) shift_embossed_prop(window, CHORUS_GADGET, -1, 0);
send_pc_and_note(tool, functions->timenow, 60);
break;
case CHORUSUP_GADGET:
tool->chorus = (UBYTE) shift_embossed_prop(window, CHORUS_GADGET, 1, 0);
send_pc_and_note(tool, functions->timenow, 60);
break;
case VARIATION_GADGET:
tool->variation = (UBYTE) drag_embossed_prop(window, VARIATION_GADGET, 0);
send_pc_and_note(tool, functions->timenow, 60);
break;
case VARIATIONDOWN_GADGET:
tool->variation = (UBYTE) shift_embossed_prop(window, VARIATION_GADGET, -1, 0);
send_pc_and_note(tool, functions->timenow, 60);
break;
case VARIATIONUP_GADGET:
tool->variation = (UBYTE) shift_embossed_prop(window, VARIATION_GADGET, 1, 0);
send_pc_and_note(tool, functions->timenow, 60);
break;
case HARMONIC_GADGET:
tool->harmonic = (UBYTE) drag_embossed_prop(window, HARMONIC_GADGET, 0);
send_pc_and_note(tool, functions->timenow, 60);
break;
case HARMONICDOWN_GADGET:
tool->harmonic = (UBYTE) shift_embossed_prop(window, HARMONIC_GADGET, -1, 0);
send_pc_and_note(tool, functions->timenow, 60);
break;
case HARMONICUP_GADGET:
tool->harmonic = (UBYTE) shift_embossed_prop(window, HARMONIC_GADGET, 1, 0);
send_pc_and_note(tool, functions->timenow, 60);
break;
case BRIGHT_GADGET:
tool->bright = (UBYTE) drag_embossed_prop(window, BRIGHT_GADGET, 0);
send_pc_and_note(tool, functions->timenow, 60);
break;
case BRIGHTDOWN_GADGET:
tool->bright = (UBYTE) shift_embossed_prop(window, BRIGHT_GADGET, -1, 0);
send_pc_and_note(tool, functions->timenow, 60);
break;
case BRIGHTUP_GADGET:
tool->bright = (UBYTE) shift_embossed_prop(window, BRIGHT_GADGET, 1, 0);
send_pc_and_note(tool, functions->timenow, 60);
break;
case VIBRATO_GADGET:
tool->vibrato = (UBYTE) drag_embossed_prop(window, VIBRATO_GADGET, 0);
send_pc_and_note(tool, functions->timenow, 60);
break;
case VIBRATODOWN_GADGET:
tool->vibrato = (UBYTE) shift_embossed_prop(window, VIBRATO_GADGET, -1, 0);
send_pc_and_note(tool, functions->timenow, 60);
break;
case VIBRATOUP_GADGET:
tool->vibrato = (UBYTE) shift_embossed_prop(window, VIBRATO_GADGET, 1, 0);
send_pc_and_note(tool, functions->timenow, 60);
break;
case EXPRESSION_GADGET:
tool->expression = (UBYTE) drag_embossed_prop(window, EXPRESSION_GADGET, 0);
send_pc_and_note(tool, functions->timenow, 60);
break;
case EXPRESSIONDOWN_GADGET:
tool->expression = (UBYTE) shift_embossed_prop(window, EXPRESSION_GADGET, -1, 0);
send_pc_and_note(tool, functions->timenow, 60);
break;
case EXPRESSIONUP_GADGET:
tool->expression = (UBYTE) shift_embossed_prop(window, EXPRESSION_GADGET, 1, 0);
send_pc_and_note(tool, functions->timenow, 60);
break;
case ATTACK_GADGET:
tool->attack = (UBYTE) drag_embossed_prop(window, ATTACK_GADGET, 0);
send_pc_and_note(tool, functions->timenow, 60);
break;
case ATTACKDOWN_GADGET:
tool->attack = (UBYTE) shift_embossed_prop(window, ATTACK_GADGET, -1, 0);
send_pc_and_note(tool, functions->timenow, 60);
break;
case ATTACKUP_GADGET:
tool->attack = (UBYTE) shift_embossed_prop(window, ATTACK_GADGET, 1, 0);
send_pc_and_note(tool, functions->timenow, 60);
break;
case RELEASE_GADGET:
tool->release = (UBYTE) drag_embossed_prop(window, RELEASE_GADGET, 0);
send_pc_and_note(tool, functions->timenow, 60);
break;
case RELEASEDOWN_GADGET:
tool->release = (UBYTE) shift_embossed_prop(window, RELEASE_GADGET, -1, 0);
send_pc_and_note(tool, functions->timenow, 60);
break;
case RELEASEUP_GADGET:
tool->release = (UBYTE) shift_embossed_prop(window, RELEASE_GADGET, 1, 0);
send_pc_and_note(tool, functions->timenow, 60);
break;
case BANK_GADGET:
tool->bank = (UBYTE) drag_embossed_prop(window, BANK_GADGET, 0);
send_pc_and_note(tool, functions->timenow, 60);
break;
case BANKDOWN_GADGET:
tool->bank = (UBYTE)shift_embossed_prop(window, BANK_GADGET, -1, 0);
send_pc_and_note(tool, functions->timenow, 60);
break;
case BANKUP_GADGET:
tool->bank = (UBYTE) shift_embossed_prop(window, BANK_GADGET, 1, 0);
send_pc_and_note(tool, functions->timenow, 60);
break;
case PC_GADGET:
tool->pc = (UBYTE) drag_embossed_prop(window, PC_GADGET, 0);
send_pc_and_note(tool, functions->timenow, 60);
break;
case PCDOWN_GADGET:
tool->pc = (UBYTE) shift_embossed_prop(window, PC_GADGET, -1, 0);
send_pc_and_note(tool, functions->timenow, 60);
break;
case PCUP_GADGET:
tool->pc = (UBYTE) shift_embossed_prop(window, PC_GADGET, 1, 0);
send_pc_and_note(tool, functions->timenow, 60);
break;
case WRITE_GADGET:
if ((*functions->areyousure)("write to track ? Play-pointer on right place ?"))
{
if (!functions->running)
{
if (tool->insysysex != NULL) trans_hx(tool, 576, tool->insysysex, 1);
if (tool->resetsysex != NULL) trans_hx(tool, 1, tool->resetsysex, 1);
if (tool->xgonsysex != NULL) trans_hx(tool, 384, tool->xgonsysex, 1);
insert_pc(tool);
}
}
break;
case TEST_GADGET:
{
long time = functions->timenow;
send_pc(tool, time);
time += 3;
for (i = 24; i <= 84; i += 4, time += 96)
{
send_note(tool, time, i);
}
}
break;
case P01_GADGET:
if (p == 0)
{
p = 1;
tool->pc = (UBYTE) shift_embossed_prop(window, PC_GADGET, 0, 0);
send_pc_and_note(tool, functions->timenow, 60);
break;
}
else
if (p == 1)
{
p = 0;
tool->pc = (UBYTE) shift_embossed_prop(window, PC_GADGET, 0, 0);
send_pc_and_note(tool, functions->timenow, 60);
break;
}
case DEFAULT_GADGET:
{
tool->volume = 100;
tool->panpot = 64;
tool->reverb = 40;
tool->chorus = 0;
tool->variation = 40;
tool->harmonic = 64;
tool->bright = 64;
tool->vibrato = 0;
tool->expression = 127;
tool->attack = 64;
tool->release = 64;
(*functions->ModifyEmbossedProp)(window, VOLUME_GADGET, tool->volume, 0, 0, 0, 0, 0);
(*functions->ModifyEmbossedProp)(window, PANPOT_GADGET, tool->panpot, 0, 0, 0, 0, 0);
(*functions->ModifyEmbossedProp)(window, REVERB_GADGET, tool->reverb, 0, 0, 0, 0, 0);
(*functions->ModifyEmbossedProp)(window, CHORUS_GADGET, tool->chorus, 0, 0, 0, 0, 0);
(*functions->ModifyEmbossedProp)(window, VARIATION_GADGET, tool->variation, 0, 0, 0, 0, 0);
(*functions->ModifyEmbossedProp)(window, HARMONIC_GADGET, tool->harmonic, 0, 0, 0, 0, 0);
(*functions->ModifyEmbossedProp)(window, BRIGHT_GADGET, tool->bright, 0, 0, 0, 0, 0);
(*functions->ModifyEmbossedProp)(window, VIBRATO_GADGET, tool->vibrato, 0, 0, 0, 0, 0);
(*functions->ModifyEmbossedProp)(window, EXPRESSION_GADGET, tool->expression, 0, 0, 0, 0, 0);
(*functions->ModifyEmbossedProp)(window, ATTACK_GADGET, tool->attack, 0, 0, 0, 0, 0);
(*functions->ModifyEmbossedProp)(window, RELEASE_GADGET, tool->release, 0, 0, 0, 0, 0);
for (i = VOLUME_GADGET;
i <= RELEASE_GADGET;
i += 3)
{
(*functions->DrawEmbossedProp)(window, i);
}
send_pc_and_note(tool, functions->timenow+30, 60);
break;
}
case INSY_GADGET:
{
if (ins == 0)
{
ins = 1;
insy[0] = 0x53; // "S" = SYSTEM
time = functions->timenow;
tool->insysysex = "F043104C02015A01F7";
trans_hx(tool, time, tool->insysysex, 0);
send_pc_and_note(tool, functions->timenow+30, 60);
break;
}
else if (ins == 1)
{
ins = 0;
insy[0] = 0x49; //"I" = INSERTION
time = functions->timenow;
tool->insysysex = "F043104C02015A00F7";
trans_hx(tool, time, tool->insysysex, 0);
send_pc_and_note(tool, functions->timenow+30, 60);
break;
}
}
}
}
else if (class == GADGETUP)
{
/* Nothing. */
}
}
tool->tool.window = 0;
tool->tool.left = window->LeftEdge;
tool->tool.top = window->TopEdge;
tool->tool.width = window->Width;
tool->tool.height = window->Height;
tool->tool.touched = TOUCH_INIT | TOUCH_EDIT;
for (i = VOLUME_GADGET;
i <= PC_GADGET;
i += 3)
{
(*functions->FatEmbossedPropOff)(window, i, i + 1, i + 2);
}
(*functions->EmbossOff)(window, WRITE_GADGET);
(*functions->EmbossOff)(window, TEST_GADGET);
(*functions->EmbossOff)(window, P01_GADGET);
(*functions->EmbossOff)(window, DEFAULT_GADGET);
(*functions->EmbossOff)(window, INSY_GADGET);
(*functions->EmbossWindowOff)(window);
(*functions->FlashyCloseWindow)(window);
(*functions->DeleteNewWindow)(newwindow);
}
//to leave the tool correct
void __saveds removetool()
{
FreeVec(matrix);
FreeVec(MNXG);
}
//start of the tool
struct ToolMaster * inittoolmaster()
{
int i = 0, bank = 0;
if (!(MNXG=(UWORD *)AllocVec(sizeof (MNXGdata), MEMF_CHIP|MEMF_CLEAR))) return(NULL);
CopyMem(&MNXGdata, MNXG, sizeof (MNXGdata));
if(!(matrix = (STRPTR *)AllocVec(MAX_BANKS*MAX_PROGRAMS*sizeof(STRPTR), MEMF_ANY|MEMF_CLEAR)))
return(NULL);
while (v[i].bank != BE)
{
bank = v[i].bank;
matrix[bank * MAX_PROGRAMS + v[i].program] = (STRPTR)v[i].name;
i++;
}
MNXG_image.ImageData = MNXG;
memset((char *)&master, 0, sizeof(struct ToolMaster));
master.toolid = MNXG_ID;
master.image = &MNXG_image;
strcpy(master.name, MNXG_NAME);
master.edittool = edittoolcode;
master.processevent = processeventcode;
master.tooltype = MNXG_TYPE;
master.toolsize = sizeof(struct MNXGTool);
master.removetool = removetool;
return(&master);
}